package br.com.seimos.minijava.symboltable;

import java.util.Dictionary;
import java.util.Hashtable;


public class Symbol {
	
	private String name;
	private static Dictionary<String, Symbol> dict = new Hashtable<String, Symbol>();
	
	private Symbol(String n)
	{
		name = n;
	}
	
	public String toString()
	{
		return name;
	}
	
	public static Symbol symbol(String n)
	{
		String temp = n.intern();
		Symbol res = (Symbol)dict.get(temp);
		if (res == null) {
			res = new Symbol(temp);
			dict.put(temp, res);
		}
		return res;
	}
	
}
